﻿using Painter.Component;
using Painter.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Painter
{
    /// <summary>
    /// DebugWindow.xaml 的交互逻辑
    /// </summary>
    public partial class DebugWindow : Window
    {
        BitmapCanvas mCanvas=new BitmapCanvas();
        public DebugWindow(params DrawingVisual[] visual)
        {
            InitializeComponent();
            canvas.Children.Add(mCanvas);

            DrawingVisual draws = new DrawingVisual();
            draws.Copy(visual);
            mCanvas.Add(draws);
            image.Visibility = Visibility.Hidden;
            
            KeyDown += DebugWindow_KeyDown;
            MouseMove += DebugWindow_MouseMove;
        }
        public DebugWindow(params Geometry[] image)
        {
            InitializeComponent();
            foreach(Geometry geo in image)
                grid.Children.Add(new Path() { Stroke = Brushes.Black, StrokeThickness = 3, Data=geo, Fill=Brushes.Green });
            KeyDown += DebugWindow_KeyDown;
            MouseMove += DebugWindow_MouseMove;
        }
        public DebugWindow(params ImageSource[] img)
        {
            InitializeComponent();
            image.Source = img[0];
            image.Width = img[0]?.Width ?? 0;
            image.Height = img[0]?.Height ?? 0;
            KeyDown += DebugWindow_KeyDown;
            MouseMove += DebugWindow_MouseMove;
        }

        private void DebugWindow_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
                this.DragMove();
        }

        private void DebugWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
                Close();
        }
    }
}
